<?php
/**前台测试控制器
 * Created by PhpStorm.
 * User: zxj
 * Date: 17/5/2
 * Time: 上午10:52
 */

namespace App\Http\Controllers\Home;

use App\Models\Appointment;
use App\Models\Charge;
use App\Models\Favorable;
use App\Models\Member;
use App\Models\SmsLog;
use App\Models\Test;
use SimpleSoftwareIO\QrCode\Facades\QrCode;
use App\Support\PDFLib;

class TestController extends BaseController
{

    public function __construct
    (
        Appointment $appointment,
        Charge $charge,
        SmsLog $smsLog,
        Favorable $favorable,
        Member $member
    )
    {
        parent::__construct();
        $this->appointment = $appointment;
        $this->charge = $charge;
        $this->smsLog = $smsLog;
        $this->favorable = $favorable;
        $this->member = $member;
    }

    public function getIndex()
    {

//        $param['sca01'] = 264;
//        $param['cardno'] = 'bdx0000020';
//        $param['amounts'] = 5000;
//        $param['billno'] = 1495882941176;
//        $param['wxbillno'] = 22313213212;
//        $param['wxpaytime'] = date('Y-m-d H:i:s',1495882984);
//        $param['wxopenid'] = 'og_PS0ntTb1Ye8DWH3IPo0nQagiI';
//        $hiscard = apiCurl('grantCard', $param);
//        dd($hiscard);



//        $param['sca01'] = 267;
//        $param['amounts'] = 5000;
//        $res = apiCurl('lockCardNo',$param);
//        if (!$res['Result']) {
//            $ajaxData['state'] = 0;
//            $ajaxData['msg'] = '锁卡失败，请联系管理员！';
//            return ajax_return($ajaxData);
//        }
//        $cardno = $res['Cardno'];
//        return $cardno;
        $cardno = 'bdx0000868';
        $id = 9;
        $res = $this->charge->up(['id'=>$id],['card_no'=>$cardno]);
        $charge = $this->charge->getChargeInfoById($id);
        $res = $this->charge->dealOrder($charge,87515212451);
        return 1;
        $token = md5(date('Ymd', time()) . '_3');
        return $token;
    }

    public function getPay()
    {
        $result = apiCurl('regPaybyCoupon', 46);
        dd($result);
    }

    public function getIndex2()
    {

        //获取his挂号类别对应费用
        /**
         *  1    1    普通医师号    普通
         * 2    2    副主任医师号    普通
         * 3    3    主任医师号    普通
         * 4    4    专家医师号    专家
         * 5    5    知名专家医师号    专家
         * 6    6    急诊号        特需
         * 7    7    一般号        普通
         */

        $his = apiCurl('regTypeFee', array('reg_type' => 5));
        dd($his);

    }

    public function getIndex3()
    {
        /**
         * 会员账户查询
         * @param $cardno 会员卡号
         * return 数组
         *
         * VAA01 病人ID
         * NAME  姓名
         * CardType 卡类型
         * 基本余额
         * 赠送余额
         * 有效期
         * 积分余额
         */

        $his = apiCurl('memberAccountQuery', array('cardno' => 544045544));
        dd($his);

    }

    public function getIndex4()
    {

        $his_res = apiCurl('cardBinding', array('cardno' => 544045544, 'tel' => 18604276150, 'id_card' => 432155654448884, 'type' => 0));
        dd($his_res);

    }

    public function getIndex5()
    {

        /*public function his_member_bill($cardno){
            $data['cardno'] = $cardno;
            return $data;
        }*/

        //通过卡号获取就诊单据
        $his = apiCurl('memberBill', array('cardno' => 544045544));
        dd($his);

    }

    public function getIndex6()
    {
        /**
         * 获取his登记用户信息的编号
         * @param $cardno 手机号
         * @param $name 用户姓名
         * @return int 用户登记id sca01
         */

        /* public function his_get_user($params)
         {
             $data['cardno'] = $params['cardno'];
             $data['name'] = $params['name'];
             return $data;
         }*/

        $his = apiCurl('getUser', array('cardno' => 18604276150, 'name' => '张妍'));
        dd($his);

    }

    public function getIndex7()
    {


        /**
         * 获取his挂号类型
         * @param $currtime string 当前时间 2016-01-06 17:26:05
         * date('Y-m-d H:i:s', time())
         * @return mixed
        '号类ID' => string '1' (length=1)
         * '号类编码' => string '1' (length=1)
         * '号类名称' => string '普通医师号' (length=15)
         */

        $his = apiCurl('regType');
        dd($his);


    }

    public function getIndex8()
    {

        /**
         * 获取挂号类型费用
         * @param $id 传挂号类型id
         */
        /*public function his_reg_type_fee($param){
            $data['bcb01'] = $param['reg_type'];
            return $data;
        }*/

        $his = apiCurl('regTypeFee', array('reg_type' => 5));
        dd($his);

    }

    public function getIndex9()
    {

        /**
         * 传入HIS挂号类别ID，返回挂号金额
         * @param $bcb01 his挂号类别
        1	1	普通医师号	普通
         * 2    2    副主任医师号    普通
         * 3    3    主任医师号    普通
         * 4    4    专家医师号    专家
         * 5    5    知名专家医师号    专家
         * 6    6    急诊号    特需
         * 7    7    一般号    普通
         * return 挂号金额
         */

        /*public function his_reg_fee($param){
            $res = $this->getDoctorById(array('id'=>$param['id']));
            if($param['type']!=1) {
                $data['bcb01'] = $res['data']['reg_type_vip'];
            }else{
                $data['bcb01'] = $res['data']['reg_type'];
            }
            return $data;
        }*/

        $his = apiCurl('regFee');


    }

}
